/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.activity.helper;

import com.cea.papyrus.core.IPapyrusUIConstants;
import com.cea.papyrus.core.helper.DefaultModelerHelper;
import com.cea.papyrus.core.helper.GraphEdgeHelper;
import com.cea.papyrus.core.helper.NodeHelper;
import com.cea.papyrus.core.utils.Debug;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeGraphLinkHelper;
import com.cea.papyrus.diagram.classdiagram.helper.NodeCommentHelper;
import com.cea.papyrus.diagram.classdiagram.helper.NodeConstraintHelper;
import com.cea.papyrus.diagram.classdiagram.helper.NodeParameterHelper;

/**
 * Defines management of activity diagrams.
 * 
 * @author Gilles Cannenterre, Sylvain Robert
 * @since 20 fevr. 07
 */
public class ActivityDiagramModelerHelper extends DefaultModelerHelper {

	/**
	 * The EINSTANCE.
	 */
	private static ActivityDiagramModelerHelper EINSTANCE;

	/**
	 * Gets the instance.
	 * 
	 * @return this instance of ModelResourceManager
	 */
	public static ActivityDiagramModelerHelper getInstance() {
		if (EINSTANCE == null) {
			EINSTANCE = new ActivityDiagramModelerHelper();
		}
		return EINSTANCE;
	}

	/**
	 * The channel.
	 */
	private int channel = 203;

	/**
	 * The edge factory.
	 */
	protected GraphEdgeHelper edgeFactory[] = { 
			new EdgeGraphLinkHelper(), 
			new EdgeControlFlowHelper(),
			new EdgeObjectFlowHelper(),
			};
	

	// set of connections
	/**
	 * The edge types.
	 */
	protected Class edgeTypes[] = { 
			com.cea.papyrus.core.pseudoelement.GraphicalLink.class,
			org.eclipse.uml2.uml.ControlFlow.class,
			org.eclipse.uml2.uml.ObjectFlow.class,
	};

	// Set Uml element that can be created
	/**
	 * The element types.
	 */
	protected Class elementTypes[] = { 
			org.eclipse.uml2.uml.Element.class,
			org.eclipse.uml2.uml.Comment.class,
			org.eclipse.uml2.uml.Constraint.class,
			org.eclipse.uml2.uml.AcceptCallAction.class,
			org.eclipse.uml2.uml.CentralBufferNode.class,
			org.eclipse.uml2.uml.Activity.class,
			org.eclipse.uml2.uml.ActivityParameterNode.class,
			org.eclipse.uml2.uml.InputPin.class,
			org.eclipse.uml2.uml.OutputPin.class,
			org.eclipse.uml2.uml.ActionInputPin.class,
			org.eclipse.uml2.uml.DataStoreNode.class,
			org.eclipse.uml2.uml.AcceptEventAction.class,
			org.eclipse.uml2.uml.AddVariableValueAction.class,
			org.eclipse.uml2.uml.CallBehaviorAction.class,
			org.eclipse.uml2.uml.CallOperationAction.class,
			org.eclipse.uml2.uml.SendSignalAction.class,
			org.eclipse.uml2.uml.SendObjectAction.class,
			org.eclipse.uml2.uml.UnmarshallAction.class,
			org.eclipse.uml2.uml.ValueSpecificationAction.class,
			org.eclipse.uml2.uml.DecisionNode.class,
			org.eclipse.uml2.uml.ActivityFinalNode.class,
			org.eclipse.uml2.uml.FlowFinalNode.class,
			org.eclipse.uml2.uml.ForkNode.class,
			org.eclipse.uml2.uml.InitialNode.class,
			org.eclipse.uml2.uml.JoinNode.class,
			org.eclipse.uml2.uml.MergeNode.class,
			org.eclipse.uml2.uml.Parameter.class,
			org.eclipse.uml2.uml.OpaqueAction.class,
			org.eclipse.uml2.uml.BroadcastSignalAction.class,
			org.eclipse.uml2.uml.TestIdentityAction.class,
			org.eclipse.uml2.uml.CreateObjectAction.class,
			org.eclipse.uml2.uml.DestroyObjectAction.class,
			org.eclipse.uml2.uml.AddStructuralFeatureValueAction.class,
			org.eclipse.uml2.uml.ReadExtentAction.class,
			};

	// Set of factory that are in the same order that elment types
	/**
	 * The node factory.
	 */
	protected NodeHelper nodeFactory[] = { 
			new NodeHelper(),
			new NodeCommentHelper(),
			new NodeConstraintHelper(),
			new NodeAcceptCallActionHelper(),
			new NodeCentralBufferNodeHelper(),
			new NodeActivityHelper(),
			new NodeActivityParameterNodeHelper(),
			new NodeInputPinHelper(),
			new NodeOutputPinHelper(),
			new NodeActionInputPinHelper(),
			new NodeDataStoreNodeHelper(),
			new NodeAcceptEventActionHelper(),
			new NodeAddVariableValueActionHelper(),
			new NodeCallBehaviorActionHelper(),
			new NodeCallOperationActionHelper(),
			new NodeSendSignalActionHelper(),
			new NodeSendObjectActionHelper(),
			new NodeUnmarshallActionHelper(),
			new NodeValueSpecificationActionHelper(),
			new NodeDecisionNodeHelper(),
			new NodeActivityFinalNodeHelper(),
			new NodeFlowFinalNodeHelper(),
			new NodeForkNodeHelper(),
			new NodeInitialNodeHelper(),
			new NodeJoinNodeHelper(),
			new NodeMergeNodeHelper(),
			new NodeParameterHelper(),
			new NodeOpaqueActionHelper(),
			new NodeBroadcastSignalActionHelper(),
			new NodeTestIdentityActionHelper(),
			new NodeCreateObjectActionHelper(),
			new NodeDestroyObjectActionHelper(),
			new NodeAddStructuralFeatureActionHelper(),
			new NodeReadExtentActionHelper(),
			
			};

	/**
	 * Create the factories for model elements.
	 */
	public ActivityDiagramModelerHelper() {
		Debug.debug(this, "ActivityDiagramModelerHelper()", channel);
		for (int i = 0; i < elementTypes.length; i++) {
			creationFactoryMap.put(elementTypes[i], nodeFactory[i]);
		}
		for (int i = 0; i < edgeTypes.length; i++) {
			creationFactoryMap.put(edgeTypes[i], edgeFactory[i]);
		}
	}

	
	/**
	 * Gets the id.
	 * 
	 * @return the id
	 */
	@Override
	public String getId() {
		return IPapyrusUIConstants.ACTIVITY_DIAGRAM;
	}
}